package com.dtgrid.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import net.sf.json.JSONObject;

import com.dtgrid.model.Pager;
import com.dtgrid.utils.ExportUtils;
import com.dtgrid.utils.PagerPropertyUtils;
import com.jfinal.core.Controller;

/**
 * dtGrid导出
 * @author 大连首闻科技有限公司
 * @version 1.0
 */
public class ExportController extends Controller{
	
	
	public void index() throws Exception {
		Object dtGridPager = getPara("dtGridPager");
		JSONObject jb = JSONObject.fromObject(dtGridPager);
		Pager pager = PagerPropertyUtils.copy(jb);
		ExportUtils.export(getRequest(), getResponse(), pager);
		
		renderNull();
		
	}
	/**
	 * 执行导出
	 * @param dtGridPager Pager对象
	 * @param request 请求对象
	 * @param response 响应对象
	 * @throws Exception
	 */
	public void export(String dtGridPager, HttpServletRequest request, HttpServletResponse response) throws Exception {
		Pager pager = PagerPropertyUtils.copy(JSONObject.fromObject(dtGridPager));
		ExportUtils.export(request, response, pager);
	}

}